<?php
/*
 * This class generates common functions, e.g. creating links
 * 
 * (reason for this is that we need to include BASE_PATH later on
 *  and that would be an "ugly" way to write for each link in the views)
 */

class Html {

    /*
     * Creates a link
     * - if path is set to null, direct to base_path
     */
    function link($text,$path) {
        // if path is empty, direct to main
        if(!$path){
            $data = '<a href="'.BASE_PATH.'">'.$text.'</a>';
        }
        else {
            $path = str_replace(' ','-',$path);
            $data = '<a href="'.BASE_PATH . $path.'">'.$text.'</a>';
        }
        return $data;
    }


    /*
     * Creates a image
     * - id and class is optional
     */
    function img($fileName, $title, $id=null, $class=null){
        $data = '<img src="'.BASE_PATH.'img/'.$fileName.'" title="'.$title.'" ';
        if($id)
            $data .= 'id="'.$id.'" ';
        if($class)
            $data .= 'class="'.$class.'" ';
        $data .= '/>';

        return $data;
    }


    /*
     * Include a JS file
     */
    function js($fileName) {
        $data = '<script src="'.BASE_PATH.'js/'.$fileName.'.js"></script>';
        return $data;
    }

    /*
     * Include a CSS file
     */
    function css($fileName) {
        $data = '<link rel="stylesheet" type="text/css" href="' . BASE_PATH . 'css/' . $fileName . '.css" media="screen" />';
        return $data;
    }
}
?>